/********************************************************************************
* File Name:	fileproperty.cpp
* Description:	第12章实例训练          
* Reference book:《Linux环境下Qt4图形界面与MySQL编程》，机械工业出版社.2012.1  
* E_mail: openlinux2011@gmail.com		                
*
********************************************************************************/
#include "fileproperty.h"
#include "ui_fileproperty.h"

//文件属性类构造函数
FileProperty::FileProperty(QWidget *parent) :QDialog(parent),ui(new Ui::FileProperty)
{
    ui->setupUi(this);
}

FileProperty::~FileProperty()
{
    delete ui;
}

void FileProperty::showMovieProperty(QString fileName) //获取文件属性并显示
{
    QFileInfo info(fileName);
    QString basename = info.completeBaseName(); //文件名，出去路径部分
    QString suffixname = info.completeSuffix(); //文件后缀
    QString absolutefilepath = info.absoluteFilePath(); //文件绝对路径
    qint64 size = info.size(); //文件大小，单位byte
    size = size/1024; //转换成KB
    QDateTime created = info.created(); //获取文件的创建时间
    QDateTime lastRead = info.lastRead(); //获取文件的上次读取时间

    //显示文件属性
    ui->leFileName->setText(basename+"."+suffixname);
    ui->leSize->setText(QString::number(size)+"KB");
    ui->leCreateTime->setText(created.toString());
    ui->leFilePath->setText(absolutefilepath);
    ui->leLastVisit->setText(lastRead.toString());
    show(); //显示文件属性框
}
